Skip to content

[codex] Allow public search suggestions#1388

Open
auggernaut wants to merge 1 commit into
emdash-cms:mainfrom
auggernaut:codex/public-search-suggestions
Open

[codex] Allow public search suggestions#1388
auggernaut wants to merge 1 commit into
emdash-cms:mainfrom
auggernaut:codex/public-search-suggestions

Conversation

@auggernaut

Copy link
Copy Markdown
Contributor

What does this PR do?

Allows anonymous GET requests to /_emdash/api/search/suggest so the built-in LiveSearch autocomplete mode works on public sites.

The route is added as an exact public API match alongside /_emdash/api/search; search management endpoints such as /_emdash/api/search/rebuild remain authenticated. The suggestion query still only returns published content, with a regression test covering draft exclusion.

Closes #

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main.
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/...

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Codex / GPT-5

Screenshots / test output

  • pnpm --silent lint:json | jq '.diagnostics | length' -> 0
  • pnpm --silent lint:quick
  • pnpm --dir packages/core exec vitest run tests/unit/middleware/oauth-csrf.test.ts tests/integration/search/suggest.test.ts -> 20 tests passed
  • pnpm --dir packages/core typecheck
  • pnpm --filter emdash build
  • pnpm lint
  • pnpm typecheck
  • pnpm format
  • git diff --check

@changeset-bot

changeset-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 49fd03d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@auggernaut

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot added area/core size/M review/needs-review No maintainer or bot review yet labels Jun 8, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1388

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1388

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1388

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1388

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1388

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1388

emdash

npm i https://pkg.pr.new/emdash@1388

create-emdash

npm i https://pkg.pr.new/create-emdash@1388

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1388

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1388

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1388

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1388

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1388

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1388

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1388

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1388

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1388

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1388

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1388

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1388

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1388

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1388

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1388

commit: 49fd03d

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean, minimal bug fix that correctly allows anonymous GET access to /_emdash/api/search/suggest by adding it to PUBLIC_API_EXACT, mirroring the existing public /_emdash/api/search route. The approach is sound: the endpoint is read-only, the underlying query already hardcodes status = 'published' and respects soft-deletion, and management endpoints (/rebuild, /enable, /stats) remain protected by auth middleware and the existing token-scope rules.

I verified:

  • Auth middleware: isPublicEmDashRoute uses exact matching, so sibling management routes are not accidentally exposed.
  • Scope enforcement: Token-authenticated GET requests to search/suggest still require content:read scope via the existing prefix rule; anonymous requests bypass scope checks as intended.
  • CSRF: GET/HEAD on public routes skip CSRF, which is safe since the route only exports a GET handler.
  • SQL: The suggestion query uses Kysely parameterized values and validateIdentifier for collection slugs; no injection risk.
  • Tests: The unit tests in oauth-csrf.test.ts correctly verify anonymous access and continued privacy of search/rebuild. The integration test adds a proper draft-exclusion regression test. The test-helper fix to omit body on GET/HEAD is a nice cleanup.
  • Changeset: Accurate patch-level changeset for the emdash package.

I found no logic bugs, regressions, or AGENTS.md convention violations. Good to go.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core review/approved Approved; no new commits since size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant